<?php

$menumark = 'houseimg';
switch ($act) {
    //#####################@ 修改分类 @#####################//
    case 'edit':
        if(isGet()){
            $house = $db->pe_selectall('house');
            $houseimg = $db->pe_select('houseimg',array('houseimg_id'=>$_g_id));
            include(pe_tpl('houseimg_edit.html'));
        }else if(isPost()){
            if ($_FILES['houseimg_img']['size']) {
                pe_lead('include/class/upload.class.php');
                $upload = new upload($_FILES['houseimg_img']);
                $_p_info['houseimg_img'] = $upload->filehost;
            }
            if($db->pe_update('houseimg',array('houseimg_id'=>$_g_id),$_p_info)){
                pe_success('修改成功');
            }else{
                pe_error('修改失败');
            }


        }

        break;

    case 'add':
        if(isGet()){
            $house = $db->pe_selectall('house');

        }else if(isPost()){
            if ($_FILES['houseimg_img']['size']) {
                pe_lead('include/class/upload.class.php');
                $upload = new upload($_FILES['houseimg_img']);
                $_p_info['houseimg_img'] = $upload->filehost;
            }
          if($db->pe_insert('houseimg',$_p_info)){
                pe_success('新增成功');
          }else{
              pe_error('新增失败');
          }


        }
        include(pe_tpl('houseimg_add.html'));
        break;


    case 'find':

        $house = $db->pe_select('house',array('house_name'=>$_p_house_name));

        $sql = 'select hi.houseimg_id,hi.houseimg_img,hi.houseimg_houseid,hi.houseimg_order,hi.houseimg_state,ho.house_name from wxgg_houseimg as hi join wxgg_house as ho on hi.houseimg_houseid =' . $house['house_id'];
        $house_img = $db->sql_selectall($sql);
        include(pe_tpl('houseimg_list.html'));
        break;


    case 'del':
        pe_token_match();
        $result = $db->pe_delete('houseimg', array('houseimg_id' => $_g_id));
        //同时删除wxgg_fj里的相同房型，wxgg_houseimg里的相同房型
        //怎么删
        if ($result) {
            pe_success('删除成功!');
        } else {
            pe_error('删除失败...');
        }
        include(pe_tpl('houseimg_list.html'));
        break;
    //#####################@ 分类列表 @#####################//
    default :
        $sql = 'select hi.houseimg_id,hi.houseimg_img,hi.houseimg_houseid,hi.houseimg_order,hi.houseimg_state,ho.house_name from wxgg_houseimg as hi join wxgg_house as ho on hi.houseimg_houseid = house_id ';
        $house_img = $db->sql_selectall($sql);
//        mp($house_img);exit;
        include(pe_tpl('houseimg_list.html'));

        break;
}